unit MoveImageButton;

interface

uses
  Windows, Messages, SysUtils, Classes, Controls, ExtCtrls,Graphics;

type
  TMoveImgBtn = class(TImage)
  private
    { Private declarations }
    procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
    procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
    procedure CMEnabledChanged(var Message: TMessage); message CM_ENABLEDCHANGED;
  protected
    { Protected declarations }
  public
    { Public declarations }
    constructor Create(aOwner: TComponent); override;
    destructor Destroy; override;

  published
    { Published declarations }
    property Action;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Wuqiu', [TMoveImgBtn]);
end;

procedure TMoveImgBtn.CMMouseEnter(var Message: TMessage);
begin
  inherited;
  if self.Enabled  then
  begin
    Left:=Left-1;
    Top:=Top-1;
  end;
end;

procedure TMoveImgBtn.CMMouseLeave(var Message: TMessage);
begin
  inherited;
  if self.Enabled  then
  begin
    Left:=Left+1;
    Top:=Top+1;
  end;
end;

procedure TMoveImgBtn.CMEnabledChanged(var Message: TMessage);
begin
  inherited;
  Invalidate;
end;

constructor TMoveImgBtn.Create(aOwner: TComponent);
begin
  inherited Create(aOwner);
  Cursor:=crHandPoint;
  AutoSize:=true;
end;

destructor TMoveImgBtn.Destroy;
begin
  inherited Destroy;
end;

end.
